home *** CD-ROM | disk | FTP | other *** search
/ Disc to the Future 2 / Disc to the Future Part II Programmer's Reference (Wayzata Technology)(6013)(1992).bin / MAC / THINKC / 4_0 / GETFILEN.C1 < prev    next >
Text File  |  1992-05-30  |  2KB  |  81 lines

  1. /********************************/
  2. /* File: GetFileName.c            */
  3. /*                                */
  4. /* Using Standard File Package    */
  5. /* query the user for the name    */
  6. /* of a file to open, and return*/
  7. /* the name along with the         */
  8. /* working directory id of the    */
  9. /* file.                        */
  10. /*                                */
  11. /* Paramters:                    */
  12. /* paramCnt = number of types    */
  13. /* params[0..3] = the types to     */
  14. /* filter for (see Inside Mac.    */
  15. /* I-523 for details            */    
  16. /* ----------------------------    */
  17. /* To Build:                    */
  18. /*                                 */
  19. /* (1) Create a project using    */
  20. /* this file as well as the     */
  21. /* XCMD.Glue.c file. (Set         */
  22. /* project type to     XCMD (or    */
  23. /* XFCN) from the Project menu.    */
  24. /*                                */
  25. /* (2) Bring the project up to    */
  26. /* date.                        */
  27. /*                                */
  28. /* (3) Build Code Resource.     */
  29. /*                                */
  30. /* (4) Use ResEdit to copy the     */
  31. /* resource to your stack.        */
  32. /********************************/
  33.  
  34. #include    <MacTypes.h>
  35. #include    <OSUtil.h>
  36. #include    <MemoryMgr.h>
  37. #include    <FileMgr.h>
  38. #include    <ResourceMgr.h>
  39. #include    <pascal.h>
  40. #include    <strings.h>
  41. #include     "HyperXCmd.h"
  42. #include    "HyperUtils.h"
  43.  
  44. pascal void main( paramPtr )
  45.     XCmdBlockPtr    paramPtr;
  46. {
  47.     short        FileWDID;
  48.     long        temp;
  49.     short        numTypes;
  50.     short        i;
  51.     SFTypeList    typs;
  52.     char        FileName[256];
  53.     char        WDIDString[32];
  54.     char        comma[2];
  55.     
  56.     if( !paramPtr->paramCount )
  57.         numTypes    = -1;         /* select all since no type specified */
  58.     else{
  59.         numTypes = paramPtr->paramCount;
  60.         for( i = 0; i < numTypes; i++ )
  61.             BlockMove( *(paramPtr->params[i]), &typs[i], 4L );
  62.     }
  63.     
  64.     *FileName = '\0';
  65.     
  66.     if( GetFileNameToOpen( typs, numTypes, FileName, &FileWDID ) ){
  67.         temp = (long)FileWDID & 0xFFFF;
  68.         NumToStr( paramPtr, temp, &WDIDString );
  69.         PtoCstr( WDIDString );
  70.         
  71.         comma[0] = ',';        /* for you MPW folk */
  72.         comma[1] = '\0';
  73.         
  74.         strcat( FileName, comma );
  75.         strcat( FileName, WDIDString );
  76.         CtoPstr( FileName );
  77.     }
  78.     paramPtr->returnValue = PasToZero( paramPtr, FileName );
  79. }
  80.  
  81.